package io.renren.modules.department.controller;

import java.util.Arrays;
import java.util.Map;

import io.renren.common.validator.ValidatorUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.renren.modules.department.entity.PersonnelDepartInforEntity;
import io.renren.modules.department.service.PersonnelDepartInforService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;



/**
 * 人事部成员表
 *
 * @author Mark
 * @email sunlightcs@gmail.com
 * @date 2021-12-31 10:59:45
 */
@RestController
@RequestMapping("department/personneldepartinfor")
public class PersonnelDepartInforController {
    @Autowired
    private PersonnelDepartInforService personnelDepartInforService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("department:personneldepartinfor:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = personnelDepartInforService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{personnelDepartId}")
    @RequiresPermissions("department:personneldepartinfor:info")
    public R info(@PathVariable("personnelDepartId") Long personnelDepartId){
        PersonnelDepartInforEntity personnelDepartInfor = personnelDepartInforService.getById(personnelDepartId);

        return R.ok().put("personnelDepartInfor", personnelDepartInfor);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("department:personneldepartinfor:save")
    public R save(@RequestBody PersonnelDepartInforEntity personnelDepartInfor){
        personnelDepartInforService.save(personnelDepartInfor);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("department:personneldepartinfor:update")
    public R update(@RequestBody PersonnelDepartInforEntity personnelDepartInfor){
        ValidatorUtils.validateEntity(personnelDepartInfor);
        personnelDepartInforService.updateById(personnelDepartInfor);
        
        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("department:personneldepartinfor:delete")
    public R delete(@RequestBody Long[] personnelDepartIds){
        personnelDepartInforService.removeByIds(Arrays.asList(personnelDepartIds));

        return R.ok();
    }

}
